package com.sl.hx.shop.ui.home.presenter;

import android.content.Context;

import com.sl.hx.shop.base.BasePresenter;
import com.sl.hx.shop.bean.FlashSaleList;
import com.sl.hx.shop.http.ApiFactory;
import com.sl.hx.shop.http.ApiRetrofit;
import com.sl.hx.shop.http.HttpUtil;
import com.sl.hx.shop.http.ProgressSubscribe;
import com.sl.hx.shop.ui.home.contacts.FlashSaleContacts;
import com.trello.rxlifecycle2.android.FragmentEvent;
import java.util.List;
import io.reactivex.Observable;


public class FlashSalePresenter extends BasePresenter<FlashSaleContacts.view> implements FlashSaleContacts.presenter {

    private Context mContext;


    public FlashSalePresenter(Context context) {
        this.mContext=context;

    }


    public void getFlashSale(String s, String s1, int page, int num) {
        Observable observable = ApiFactory.getInstance().getFlashSale(ApiRetrofit.getCacheControl(),s,s1,1,page,num);
        HttpUtil.getInstance().toSubscribe(observable, new ProgressSubscribe<List<FlashSaleList>>(mContext) {
            @Override
            protected void _onNext(List<FlashSaleList> flashSaleLists) {
                getView().ShowFlashSale(flashSaleLists);
            }

            @Override
            protected void _onError(String message) {
            }

        }, true, getView(), FragmentEvent.DESTROY);
    }
}
